<extend name="Common/index" />
<block name="content">
	<link rel="stylesheet" href="__PUBLIC__/lib/layui/css/layui.css" media="all">
	<div class="page-container">
		<table id="table" class="table table-border table-bordered table-hover table-bg">
			<thead>
				<tr>
					<th scope="col" colspan="12">
						<a class="btn btn-primary radius" href="javascript:;" onclick="layer_show('添加行政区','{:U('Ziyuan/addxzq')}','420','210')">
							<i class="Hui-iconfont">&#xe600;</i> 添加行政区
						</a>
						<span style="float: right;">
							<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
								<i class="Hui-iconfont">&#xe68f;</i>
							</a>
						</span>
					</th>
				</tr>
				<tr class="text-c">
					<th width="40">序号</th>
					<th width="80">行政区名</th>
					<th width="80">操作</th>
				</tr>
			</thead>
			<tbody id="xsjxzq">
				<volist name="xingzhengqu" id="xzq">
					<tr class="text-c">
						<td>{$i}</td>
						<td>
							{$xzq.xzqming}
						</td>
						<td class="f-14" id="td">
							<a title="编辑" href="javascript:;" onclick="layer_show('编辑行政区','{:U('Ziyuan/editxzq',array('id'=>$xzq['id']))}','420','210')" style="text-decoration:none" class="ml-5">
								<i class="Hui-iconfont" style="font-size: 18px;">&#xe6df;</i>
							</a>
							<a title="删除" href="javascript:;" onclick="admin_xzq_del(this,'{$xzq.id}')" class="ml-5" style="text-decoration:none">
								<i class="Hui-iconfont" style="font-size: 22px;">&#xe6e2;</i>
							</a>
						</td>
					</tr>
				</volist>
			</tbody>
		</table>
		<div style="height: 50px;"></div>
	</div>
</block>
<block name="js">
	<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script> 
	<script type="text/javascript" src="__PUBLIC__/lib/layer/2.4/layer.js"></script>
	<script src="__PUBLIC__/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript">
		$("#table").on("click","#td a",function(){
			Hui_admin_tab(this);
		});
		function admin_xzq_del(obj,id){
			layer.confirm('小区删除须谨慎，确认要删除吗？',function(index){
				$.ajax({
					type: 'POST',
					url: '{:U('Ziyuan/delxzq')}',
					data: {'id':id},
					dataType: 'json',
					success: function(data){
						$(obj).parents("tr").remove();
						layer.msg('已删除!',{icon:1,time:1000});
					},
					error:function(data) {
						console.log(data.msg);
					},
				});
			});
		}
		function xsjxzq(){
			$.ajax({
				url:'{:U('Ziyuan/get_xzqxsj')}',
				Type:"POST",
				dataType:"json",
				success:function(data){
					var pics = data.pics;
					var sj='<tr class="text-c"><td style="color:red">new</td><td>'+pics["xzqming"]+'</td><td></td></tr>';
					$("#xsjxzq").prepend(sj);
				}
			});
		};
	</script>
</block>